<?php
namespace Admin\Controller;
use Think\Controller;
class MasterController extends Controller {
    public function index(){
        $this->display();
    }
    public function masterlist(){
		
		$mastermodel=M('master');
		$masters=$mastermodel->order('mid ')->select();
		$this->master=$masters;
		$this->display();
	}
	public function delmaster($mid){
	$mastermodel=M('master');	
	if (false!==$mastermodel->where("mid=$mid")->delete()) {
            $this->success('删除成功！');
        } else {
            $this->error('删除失败');
        }
		
	}
    public   function acadd(){
        // $mastername=$_POST['mastername'];
        // $masterdate=$_POST['masterdate'];
        // $masterplace=$_POST['masterplace'];
        // $charge=$_POST['charge'];
        // $atel=$_POST['atel'];
        // $acontent=$_POST['acontent'];
        // $mastermodel=M('master');
        // if ($mastermodel->create()) {
            
        //     if (false !==$mastermodel->add()) {
        //         //echo $user->getLastSql();
        //         $this->success('添加成功！', 'masterlist');
        //     }
        //     else
        //     {
        //         $this->error('添加失败','masterlist');
        //     }
        // }
        // }



        $masters = D('master'); 
              $mid=I('post.mid');
        $data['mname']=I('post.mname');
        $data['mcourses']=I('post.mcourses');
        $data['mclassify']=I('post.mclassify');
        $data['mpicture']=I('post.mpicture');
        $data['msurname']=I('post.msurname');
        $data['mcontent']=I('post.mcontent');
        $data['mquestion']=I('post.mquestion');
        // $data['classid']=S('classid');
        dump($data);
        
         if(false!==$masters->add($data)){
             $this->success('成功','masterlist');
         }else{
            $this->error('失败','masterlist');
         }
        }

        public   function editac(){

              $masters = D('master'); 
              $mid=I('post.mid');
        $data['mname']=I('post.mname');
        $data['mcourses']=I('post.mcourses');
        $data['mclassify']=I('post.mclassify');
        $data['mpicture']=I('post.mpicture');
        $data['msurname']=I('post.msurname');
        $data['mcontent']=I('post.mcontent');
        $data['mquestion']=I('post.mquestion');
        dump($data);
        if(false !== $masters->where("mid=$mid")->save($data)){
            $this->success('成功','masterlist');
         }else{
            $this->error('失败');
         }
        }
        public function edit(){    
            $masters = D('master'); 
            $mid=$_GET['mid'];
            $res= $masters->where("mid=$mid")->find();
            $this->master=$res;
         
        $this->display();
        }
}